home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // http://cinema.ptgate.pt/(imagem pequena)
- // Script feito pelo O Guardiπo versπo 1.0 Alpha 2
- // 29-05-2004
-
-
- (***************************************************
- * For use with Ant Movie Catalog 3.4.0 *
- * www.antp.be/software/moviecatalog *
- * *
- * The source code of the script can be used in *
- * another program only if full credits to *
- * script author and a link to Ant Movie Catalog *
- * website are given in the About box or in *
- * the documentation of the program *
- * *
- * Please dont remove credits *
- * Reportem os erros para bruno_mga@hotmail.com *
- ***************************************************)
- program PTGate;
- const
- BaseAddress = 'http://cinema.ptgate.pt/';
- ManualPictureSelect = True;
- ExternalPictures = False;
- DescriptionToImport = 2;
- var
- MovieName: string;
- MovieURL: string;
- function HTMLRemove(Value: String): String;
- begin
- HTMLDecode(Value);
- HTMLRemoveTags(Value);
- Value := Trim(Value);
- result := Value;
- end;
-
- procedure AnalyzeFilmPage(Address: String);
- var
- Page : TStringList;
- Line, Value : string;
- LineNr, BeginPos, EndPos: Integer;
- AllTitles: TStringList;
- url_imdb:string;
- begin
- Page := TStringList.Create;
- Address:='http://cinema.ptgate.pt/filme.php?code='+Address;
- Page.Text := GetPage(Address);
- SetField(fieldURL, Address);
-
-
-
- //obter nome do filme
- LineNr := FindLine('<td bgcolor=#6496D2 width=360 colspan=2><table border=0 cellspacing=0 cellpadding=0><td width=5><br></td><td><font color=white><b class=ttl>', Page, 0);
- if LineNr<>-1 then
- begin
- Value := Page.GetString(LineNr+1);
- BeginPos := pos('</b><br><', value)+9;
- value:=copy(value,4,BeginPos);
-
- AllTitles := TStringList.Create;
- AllTitles.Add(HTMLRemove(value));
-
- //por o the no principio do nome
- if pos(', The</b><br>',value) <>0 then
- begin
- url_imdb:=HTMLRemove(value);
- value:= StringReplace(value, ', The</b><br>', '');
- value:='The '+value;
- value:=HTMLRemove(value);
- AllTitles.Add(value);
- end;
-
- value:=HTMLRemove(value);
- SetField(fieldOriginalTitle, Value);
- end;
-
- //imagem
- Value := Page.GetString(LineNr-1);
- Value:= StringReplace(value, ' "></td>', '');
- Value:= StringReplace(value, ' ', '');
- Value:='http://cinema.ptgate.pt/'+value;
- GetPicture(Value, False);
-
- //obter nome traduzido
- Value := Page.GetString(LineNr+1);
- BeginPos := pos('><i class=subttl>', value)+17;
- EndPos:=Pos('<br></i></td><td width=5><br></',value);
- value:=copy(value,BeginPos,EndPos-BeginPos);
- value:=Copy(value,1,endpos);
- value:=HTMLRemove(value);
- SetField(fieldTranslatedTitle, Value);
-
-
- //Realizador
- LineNr := FindLine('<!-- real -->', Page, 0);
- if LineNr<>-1 then
- begin
- Value := Page.GetString(LineNr+3);
- BeginPos:=Pos('>',value)+1;
- EndPos:=Pos('</a>',value);
- value:=copy(value,BeginPos,EndPos-BeginPos);
- value:=HTMLRemove(value);
- SetField(fieldDirector, Value);
- end;
-
- //actores
- LineNr := FindLine('><b>IntΘrpretes: </b>', Page, 0);
- if LineNr<>-1 then
- begin
- Value := Page.GetString(LineNr+1);
- value:= StringReplace(value,' </font></td>' , '');
- value:= StringReplace(value,' ' , '');
- value:=HTMLRemove(value);
- SetField(fieldActors, Value);
- end;
-
- //ano
- LineNr := FindLine('<!-- ano -->', Page, 0);
- if LineNr<>-1 then
- begin
- Value := Page.GetString(LineNr+1);
- value:=HTMLRemove(value);
- BeginPos:=pos('Ano:',value);
- Value:=Copy(value,beginPos+6,length(value));
- SetField(fieldYear, value);
- end;
- url_imdb:=url_imdb+' ('+Value+')';
-
- //genero
- LineNr := FindLine('<!-- gene -->', Page, 0);
- if LineNr<>-1 then
- begin
- Value := Page.GetString(LineNr+1);
- BeginPos:=Pos('<font size=2 face=verdana,arial>',Value);
- EndPos:=Pos('</font></td>',Value);
- value:=Copy(value,BeginPos,EndPos-BeginPos);
- value:=HTMLRemove(value);
- SetField(fieldCategory, value);
- end;
-
- //paφs
- LineNr := FindLine('<!-- pais -->', Page, 0);
- if LineNr<>-1 then
- begin
- Value:= Page.GetString(LineNr+1);
- BeginPos:=Pos('<font size=2 face=verdana,arial>',Value);
- EndPos:=Pos('</font></td>',Value);
- value:=Copy(value,BeginPos,EndPos-BeginPos);
- value:=HTMLRemove(value);
- SetField(fieldCountry, value);
- end;
-
- //descriτπo
- LineNr := FindLine('<!-- wall -->', Page, 0);
- Value:= Page.GetString(LineNr+1);
- if (LineNr<>-1) and (pos('<b>Sinopse</b><br>',value)<>0) then
- begin
- Value:= Page.GetString(LineNr+2);
- EndPos:=Pos('<br><br></font>',value);
- Value:=Copy(Value,1,EndPos);
- Value:=HTMLRemove(value);
- SetField(fieldDescription, value);
- end;
-
- url_imdb:=AllTitles.GetString(0)+' '+url_imdb;
-
- //imdb
- url_imdb:= StringReplace(url_imdb, ' ', '+');
- url_imdb:='http://us.imdb.com/Title?'+url_imdb;
- Page.Text := GetPage(url_imdb);
-
- // Length
- LineNr := FindLine('Runtime:', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr + 1);
- EndPos := pos(' min', Line);
- if EndPos = 0 then
- EndPos := pos(' /', Line);
- if EndPos = 0 then
- EndPos := Length(Line);
- if Pos(':', Line) < EndPos then
- BeginPos := Pos(':', Line) + 1
- else
- BeginPos := 1;
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- SetField(fieldLength, Value);
- end;
-
- // Rating
- LineNr := FindLine('User Rating:', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr + 4);
- if Pos('/10', Line) > 0 then
- begin
- BeginPos := pos('<b>', Line) + 3;
- Value := IntToStr(Round(StrToInt(StrGet(Line, BeginPos), 0) + (StrToInt(StrGet(Line, BeginPos + 2), 0) / 10)));
- SetField(fieldRating, Value);
- end;
- end;
-
- LineNr := FindLine('<img border="0" alt="cover"', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('src="', Line) + 4;
- Delete(Line, 1, BeginPos);
- EndPos := pos('"', Line);
- Value := copy(Line, 1, EndPos - 1);
- GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
- end;
- end;
-
-
-
-
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr, StartPos, EndPos: Integer;
- Line: string;
- x:integer;
- MovieAddress, findMovieName,linedown : string;
- guardar,url, nome_filme:string;
- begin
- PickTreeClear;
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
-
- if (pos('Nπo foram encontrados filmes ou pessoas que satisfaτam a sua pesquisa.', Page.Text)<>-1) then //se existe
- begin
- LineNr := FindLine('filme.php?code=', Page, LineNr);
- Line := Page.GetString(LineNr);
- repeat
- StartPos := pos('filme.php?code=', Line)+15;
- if StartPos=15 then break;
-
- guardar:=Copy(line,StartPos+1,9999);
- line:=Copy(line,StartPos,9999);
- StartPos := pos('>',line)+1;
- url:=(copy(line,1,StartPos-3));
- EndPos := pos('</a>',line)-1;
- line := copy(Line, StartPos, EndPos - StartPos+1);
- nome_filme:=line;
- PickTreeAdd(nome_filme, url);
- line:=guardar;
-
- until (nome_filme='');
-
- if PickTreeExec(Address) then begin
- AnalyzeFilmPage(Address);
- end;
- Page.Free;
- end;
- DisplayResults;
- end;
- begin
- PickListClear;
- MovieName := GetField(fieldOriginalTitle);
- if Input('Importar do cinema.ptgate.pt', 'Escreva o nome do filme:', MovieName) then begin
- //espaτo nπo sπo permitidos
- MovieName := StringReplace(MovieName, ' ', '%20');
- AnalyzePage('http://cinema.ptgate.pt/pesquisa.php?tx='+MovieName);
- end;
- end.
-
-